package com.leyou.order.config;

import com.leyou.common.utils.IdWorker;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @package com.leyou.order.config
 * @description: 雪花算法配置类
 * @author: 许超越
 * @date 2019/7/13 16:56
 * @version: V1.0
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "ly.worker")
public class IdWorkerProperties {

    private long workerId;// 当前机器id

    private long dataCenterId;// 序列号

    @Bean
    public IdWorker idWorker() {
        return new IdWorker(workerId, dataCenterId);
    }
}
